home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / SciAn / src / ScianColors.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  8KB  |  266 lines

  1. /*ScianColors.h
  2.   Color management info for scian
  3.   Eric Pepke
  4.   March 15, 1990
  5. */
  6.  
  7. /*User interface color ID's and indices into palette*/
  8. #define UIBLACK        0        /*Black                */
  9. #define UIGRAY12    1        /*12.5 % Gray            */
  10. #define UIGRAY25    2        /*25 % Gray            */
  11. #define UIGRAY37    3        /*37.5 % Gray            */
  12. #define UIGRAY50    4        /*50 % Gray            */
  13. #define UIGRAY62    5        /*62.5 % Gray            */
  14. #define UIGRAY75    6        /*75 % Gray            */
  15. #define UIGRAY87    7        /*87.5 % Gray            */
  16. #define UIWHITE        8        /*White                */
  17. #define UIRED        9        /*Bright red            */
  18. #define UIGREEN        10        /*Bright green            */
  19. #define UIBLUE        11        /*Bright blue            */
  20. #define UIMAGENTA    12        /*Bright magenta        */
  21. #define UIYELLOW    13        /*Bright yellow            */
  22. #define UICYAN        14        /*Bright cyan            */
  23. #define UIGOLD        15        /*Gold (as in garnet and)    */
  24.  
  25. #define NPUREUICOLORS    16        /*16 pure UI colors        */
  26.  
  27. #define UIPRED        16        /*Pastel red (pink)        */
  28. #define UIPINK        16        /*Another name for pink        */
  29. #define UIPGREEN    17        /*Pastel green            */
  30. #define UIPBLUE        18        /*Pastel blue            */
  31. #define UIPMAGENTA    19        /*Pastel magenta        */
  32. #define UIPYELLOW    20        /*Pastel yellow            */
  33. #define UIPCYAN        21        /*Pastel cyan            */
  34. #define NUICOLORS    22        /*Total number of UI colors    */
  35.  
  36. /*Do not contrast any of the pastel colors with UIBACKGROUND!*/
  37.  
  38. /*Derived colors*/
  39. #define UIBACKGROUND    UIGRAY50    /*Panel background*/
  40. #define UIHIBACKGROUND    UIWHITE        /*Hilighted panel background*/
  41. #define UITEXT        UIBLACK        /*Color to draw unhilited text*/
  42. #define UIGREYTEXT    UIGRAY12    /*Color of greyed text*/
  43.  
  44. #define UITOPEDGE    UIWHITE        /*Top edge of a projection*/
  45. #define UILEFTEDGE    UIGRAY75    /*Left edge of a projection*/
  46. #define UIRIGHTEDGE    UIGRAY25    /*Right edge of a projection*/
  47. #define UIBOTTOMEDGE    UIGRAY12    /*Bottom edge of a projection*/
  48. #define UISHARPTOPEDGE    UIWHITE        /*Top edge of a projection*/
  49. #define UISHARPLEFTEDGE    UIWHITE        /*Left edge of a projection*/
  50. #define UISHARPRIGHTEDGE UIBLACK    /*Right edge of a projection*/
  51. #define UISHARPBOTTOMEDGE UIBLACK    /*Bottom edge of a projection*/
  52. #define UISHADOW    UIGRAY12    /*Icon shadow*/
  53. #define UIICONBACK    UIGRAY87    /*Unhilighted icon background color*/
  54. #define UIICONGREYFORE    UIGRAY25    /*Grey icon foreground*/
  55. #define UIICONGREYBACK    UIGRAY75    /*Grey icon background*/
  56. #define UIICONFORE    UIBLACK        /*Icon foreground color*/
  57. #define UIICONPIT    UIPCYAN        /*Icon Pit color*/
  58. #define UICONTROLTRACK    UIPGREEN    /*Control track color*/
  59. #define UITEXTPIT    UIPRED        /*Text Pit color*/
  60. #define UIICONHIBACK    UIWHITE        /*Highlighted icon background*/
  61. #define UIICONSELBACK    UIYELLOW    /*Selected icon background*/
  62.  
  63. /*Overlay colors*/
  64. #define UIOVERCLEAR    0        /*Clear*/
  65. #define UIOVERRED    1        /*Red*/
  66. #define UIOVERBLACK    1        /*Black*/
  67. #define UIOVERGRAY    2        /*Gray*/
  68. #define UIOVERWHITE    3        /*White*/
  69.  
  70. #define MAXCDIST    400        /*Maximum distance for color search*/
  71. #define MAXGRAYDIRT    0        /*Maximum dirtiness in gray*/
  72. #define COLORBEG8BITS    56        /*Color beg for 8 bits*/
  73. #define COLORBEGMOREBITS 256        /*Color beg for more bits*/
  74.  
  75. #define DEFPALSIZE    64        /*Default number of colors in palette*/
  76.  
  77. extern short curRed, curGreen, curBlue;
  78.  
  79. typedef short short3[3];
  80.  
  81. extern short uiColors[NUICOLORS][3];
  82.  
  83. typedef struct pal
  84.     {
  85.     Thing thing;
  86.     struct pal *next;        /*Next palette in list of active palettes*/
  87.     } Palette, *PPtr;
  88.  
  89. extern short3 *curColors;        /*The current colors*/
  90. extern int curNColors;            /*Current number of colors*/
  91. extern real curMin, curMax;        /*Current min and max values*/
  92. extern int curBeg;            /*Current beginning*/
  93. extern real diffMult;            /*Amount to multiply to get difference*/
  94.  
  95. /*Simple palette functions*/
  96. #define PF_RAMP        0        /*Interpolate a ramp*/
  97. #define PF_REVERSE    1        /*Reverse range of colors*/
  98. #define PF_RUFFLE    2        /*Ruffle range of colors*/
  99. #define PF_SMOOTH    3        /*Smooth range of colors*/
  100. #define PF_SHARPEN    4        /*Sharpen range of colors*/
  101. #define NPALETTEFUNCS    5        /*Number of palette functions*/
  102. extern char *spfNames[];
  103.  
  104. /*Color models*/
  105. #define CM_RGB        0        /*RGB color model*/
  106. #define CM_YIQ        1        /*YIQ color model*/
  107. #define CM_HSV        2        /*HSV color model*/
  108. #define CM_HLS        3        /*HLS color model*/
  109. #define NCOLORMODELS    4        /*Number of models*/
  110. extern char *colorModelNames[];
  111. extern NameTyp colorModelMethods[];
  112.  
  113. /*Palette tools*/
  114. #define PT_FREEFORM    0        /*Free form drawing*/
  115. #define PT_SINE        1        /*Sine function*/
  116. #define PT_TRIANGLE    2        /*Triangle function*/
  117. #define PT_SAWTOOTH    3        /*Sawtooth function*/
  118. #define PT_TOOTHSAW    4        /*Toothsaw function*/
  119. #define PT_SQUARE    5        /*Square wave function*/
  120. #define NPALETTETOOLS    6        /*Number of tools*/
  121.  
  122. #define SetRealColor(c)    /*Sets real color c in current palette*/    \
  123.     if (c == missingData)                        \
  124.     {                                \
  125.         if (rgbp)                            \
  126.             c3s(curColors[0]);                    \
  127.         else                            \
  128.             color((int) curBeg - 2);                \
  129.     }                                \
  130.     else if (c < curMin)                        \
  131.     {                                \
  132.         if (rgbp)                            \
  133.             c3s(curColors[1]);                    \
  134.         else                            \
  135.             color((int) (curBeg - 1));                \
  136.     }                                \
  137.     else if (c > curMax)                        \
  138.     {                                \
  139.         if (rgbp)                            \
  140.             c3s(curColors[curNColors - 1]);                \
  141.         else                            \
  142.             color((int) (curBeg + curNColors - 3));            \
  143.     }                                \
  144.     else                                \
  145.     {                                \
  146.         if (rgbp)                            \
  147.         c3s(curColors[2 + (int) (diffMult * (c - curMin))]);    \
  148.         else                            \
  149.         color((int) (curBeg + diffMult * (c - curMin)));    \
  150.     }
  151.  
  152. #define GetRealColorIndex(c)    /*Gets index or real color for data c in current palette*/\
  153.     c == missingData ?                        \
  154.         -2 :                            \
  155.     c < curMin ?                            \
  156.         -1 :                            \
  157.     c > curMax ?                            \
  158.         curNColors - 3 :                            \
  159.     (int) (diffMult * (c - curMin))                \
  160.  
  161.  
  162. #define SOLIDPAT    0        /*System pattern, solid*/
  163. #define GREYPAT        1        /*Grey pattern*/
  164. #define EVENPAT        2        /*Even pattern*/
  165. #define ODDPAT        3        /*Odd pattern*/
  166. #define EVENGREYPAT    4        /*Even grey pattern*/
  167. #define ODDGREYPAT    5        /*Odd grey pattern*/
  168.  
  169. extern int uiColorIndex[];
  170. #define RGBC(c)                    \
  171.     if (rgbp)                \
  172.     {                    \
  173.         c3f(c);                \
  174.     }                    \
  175.     else                    \
  176.     {                    \
  177.         color(uiColorIndex[ClosestUIColor(c)]);        \
  178.     }
  179.  
  180.  
  181. extern Bool rgbp;
  182. extern int overDraw;
  183.  
  184. /*Method declarations*/
  185. ObjPtr ClonePalette();
  186.  
  187. #ifdef PROTO
  188. void InitColors();
  189. void SetUIColor(int);
  190. ObjPtr NewPalette(int);
  191. void DisposePalette(ObjPtr);
  192. void InterpPalette(ObjPtr, int, int, int, int, int, int);
  193. ObjPtr NewColorWheel(int, int, int, int, char *);
  194. void HSV2RGB(real *, real *, real *, real, real, real);
  195. void RGB2HSV(real *, real *, real *, real, real, real);
  196. void HLS2RGB(real *, real *, real *, real, real, real);
  197. void RGB2HLS(real *, real *, real *, real, real, real);
  198. void YIQ2RGB(real *, real *, real *, real, real, real);
  199. void RGB2YIQ(real *, real *, real *, real, real, real);
  200. void SetPalette(ObjPtr);
  201. void SetPaletteMinMax(ObjPtr, real, real);
  202. void CopyPalette(ObjPtr, ObjPtr);
  203. void CopyAttenuatedPalette(ObjPtr, ObjPtr, real);
  204. void BlueToRedPalette(ObjPtr);
  205. void GreenToRedPalette(ObjPtr);
  206. int ClosestUIColor(float clr[3]);
  207. ObjPtr NewColorBar(int, int, int, int, char *);
  208. void ActivateColorWheel(ObjPtr, Bool);
  209. real GetColorValue(ObjPtr, int);
  210. ObjPtr SetFunctionBox(ObjPtr, ObjPtr);
  211. ObjPtr SetColorBarColor(ObjPtr, int, int, int, int);
  212. void LogColorChange(ObjPtr, short3 *colors, int);
  213. ObjPtr ImposeColorFunction(ObjPtr);
  214. void CalcGoodSteps(double, int, int, double *majorWidth, int *nMinorSteps);
  215. void CopyColorsToPalette(ObjPtr, short3 *);
  216. ObjPtr NewPaletteDisplay(int, int, int, int, char *name, ObjPtr palette);
  217. void SetObjectColor(ObjPtr);
  218. void MapPaletteColors(ObjPtr p, int start, int end);
  219. void FieldPaletteName(ObjPtr, ObjPtr);
  220. void OverDraw(Bool);
  221. void OverDrawMenus(Bool);
  222. real PSColor(void);
  223. int ChooseSelectionColor(ObjPtr);
  224. ObjPtr NewAtomicPalette(void);
  225. void TinyDelay(void);
  226. #else
  227. void InitColors();
  228. void SetUIColor();
  229. ObjPtr NewPalette();
  230. void DisposePalette();
  231. void InterpPalette();
  232. ObjPtr NewColorWheel();
  233. void HSV2RGB();
  234. void RGB2HSV();
  235. void HLS2RGB();
  236. void RGB2HLS();
  237. void YIQ2RGB();
  238. void RGB2YIQ();
  239. void SetPalette();
  240. void SetPaletteMinMax();
  241. void CopyPalette();
  242. void CopyAttenuatedPalette();
  243. void BlueToRedPalette();
  244. void GreenToRedPalette();
  245. int ClosestUIColor();
  246. ObjPtr NewColorBar();
  247. void ActivateColorWheel();
  248. real GetColorValue();
  249. ObjPtr SetFunctionBox();
  250. ObjPtr SetColorBarColor();
  251. void LogColorChange();
  252. ObjPtr ImposeColorFunction();
  253. void CalcGoodSteps();
  254. void CopyColorsToPalette();
  255. ObjPtr NewPaletteDisplay();
  256. void SetObjectColor();
  257. void MapPaletteColors();
  258. void FieldPaletteName();
  259. void OverDraw();
  260. void OverDrawMenus();
  261. real PSColor();
  262. int ChooseSelectionColor();
  263. ObjPtr NewAtomicPalette();
  264. void TinyDelay();
  265. #endif
  266.